package cn.tq.oa.service;

import cn.tq.oa.domain.Role;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @Author：张军
 * @Date:create in 2018/1/5 17:57
 * @Description:
 */
@Service
public class TestService {
    @Resource
    private SessionFactory sessionFactory;
    @Transactional
    public void saveTwoRoles() {
        Session session = sessionFactory.getCurrentSession();
        session.save(new Role());
        // int a = 1 / 0; // 这行会抛异常
        session.save(new Role());
    }
}
